#include	<stdio.h>
#include	<stdlib.h>
#include	<math.h>

typedef double Real;
typedef Real *DQMatrix;
typedef Real *DVector;

int main(int argc, char**argv)
{
  int N = 3;
  int NRHS = 1;
  int i, j, k;
  int row, col;
  int* ipiv;
  int info;
  DQMatrix A;
  DVector b;

  A = (Real*)malloc(N*N*sizeof(Real));
  b = (Real*)malloc(N*sizeof(Real));
  ipiv = (int*)malloc(N*sizeof(int));

  for( i = 0; i < N*N; i++ )
  {
    A[i] = 0.0;
  }

  A[0] = 1.0;
  A[N+1] = 2.0;
  A[2*N+2] = 3.0;

  b[0] = 1.0;
  b[1] = 1.0;
  b[2] = 1.0;


  dgesv_( &N, &NRHS, A, &N, ipiv, b, &N, &info );

  for( i = 0; i < N; i++ )
  {
    printf("%5.3f\n", b[i]);
  }

  free(A);
  free(b);
  free(ipiv);
}
